package org.gtesoreria

import jxl.Sheet;
import jxl.Workbook;

import org.springframework.web.multipart.commons.CommonsMultipartFile;


class ImportPadronController {

	static String importPadron(CommonsMultipartFile f) {
		Workbook workbook = Workbook.getWorkbook(f.inputStream)  
		 Sheet sheet = workbook.getSheet(0)  
		  
		 def added = 0;  
		 def skipped = [];  
		 for (int r = 3; r < sheet.rows; r++) {  
		  // get our fields  
		  def top = sheet.getCell(0, r).contents  
		   
		  def bottom = sheet.getCell(1, r).contents  
		  if (bottom == "") bottom = null  
		   
		  def number = sheet.getCell(2, r).contents  
		  if (number == "") number = 1  
		  
		  def spacing = sheet.getCell(3, r).contents  
		  if (spacing == "") spacing = 0.0  
		   
		  def type = sheet.getCell(4, r).contents  
		  def notes = sheet.getCell(5, r).contents  
		   
		  // check that we got a top and a type  
		  /*if (top == null || top == "") {  
		   // do nothing  
		  } else if ((new SampleRequest(  
		    "investigator":user,  
		    "hole":hole,  
		    "sampleGroup":group,  
		    "top":top,  
		    "bottom":bottom,  
		    "sampleType":type,  
		    "samplesRequested":number,  
		    "sampleSpacing":spacing,  
		    "notes":notes)).save()) {  
		   added++  
		  } else {  
		   skipped += (r + 1)  
		  }  */
		 }  
		 workbook.close() 
		 return null; 
	}  

}
